package cn.dengta.webapp.user.entity;

import java.util.Date;

import cn.dengta.webapp.base.entity.TimeBasedEntity;
import cn.dengta.webapp.user.model.AuditStatus;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 甜蜜投票日志
 *
 * @author lgy
 * @since 2022-11-09
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("act_sweet_pick")
public class ActSweetPick extends TimeBasedEntity {

	/** 用户ID */
	Long userId;
	/** 图片 */
	String image;
	/** 审核用户 */
	Long verifyUserId;
	/** 审核时间 */
	Date verifyTime;
	/** 审核备注 */
	String verifyRemark;
	/** 投票数（包含虚拟投票） */
	Integer voteCount;
	/** 虚拟投票数 */
	Integer virtualVoteCount;
	/** 分享数 */
	Integer shareCount;
	/** 钻石 */
	Integer coin;
	/** 免费钻石 */
	Integer freeCoin;
	/** 业务状态 */
	Integer status;

	public ActSweetPick init(Long userId) {
		this.userId = userId;
		this.voteCount = shareCount = coin = freeCoin = virtualVoteCount = 0;
		this.status = AuditStatus.WAIT_VERIFY.value;
		return this;
	}

	public ActSweetPick initVerify() {
		this.verifyUserId = null;
		this.verifyTime = null;
		this.verifyRemark = "";
		return this;
	}

	public Integer realVoteCount() {
		return voteCount - virtualVoteCount;
	}

	public boolean pass() {
		return AuditStatus.VERIFY_TRUE.eq(status);
	}

	public boolean canVerify() {
		return status > AuditStatus.VERIFY_FALSE.value;
	}

	public static final String USER_ID = "user_id";
	public static final String IMAGE = "image";
	public static final String VERIFY_USER_ID = "verify_user_id";
	public static final String VERIFY_TIME = "verify_time";
	public static final String VERIFY_REMARK = "verify_remark";
	public static final String VOTE_COUNT = "vote_count";
	public static final String SHARE_COUNT = "share_count";
	public static final String STATUS = "status";

}
